<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html" />
        <meta name="author" content="viet-coder.com" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Untitled 3</title>
        <link href="<?php echo base_url(); ?>public/css/index.css" rel="stylesheet" type="text/css"/>

        <script type="text/javascript" src="<?php echo base_url(); ?>public/js/jquery.colorbox.js"></script>

        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>  
        <?php
        if (!isset($_SESSION['user'])) {
            $this->load->view('login/login');
            die();
        }
        ?>

    </head>

    <body>
        <div class="contaner">
            <div class="header">
            </div>
            <div class="content">
                <div class="content-title"><a href=""><?php echo $_SESSION['user'] ?></a></div>
           <!--    <form action="<?php //echo base_url(); ?>index.php/admin/login/sendmessage" method="post"> --> 
                <input type="text" name="user_receiver"  id="user_receiver"style="width: 260px;" placeholder="User_receiver"/> <br />
                <div id="content_notification" style="width:265px;height: auto;border:1px solid ; background-color:#F0FFF0"></div>
                <div style="clear: left;"></div>
                <textarea cols="30" rows="1" name="message" id="textmessage" ></textarea>
                <input type="submit" name="send" value="Send" id="send" style="clear: both;"/>
                <!--</form>-->
            </div>

        </div>
    </body>
</html>
<script type="text/javascript">
    $(document).ready(function(){
        $("#send").click(function(){
            $.ajax({
                type: "POST", 
                url  :"<?php echo site_url('admin/login/allnotifi') ?>",
                data : null,
                success: function(data)
                {
                    $('#content_notification').html(data);
                }
            });
        });
        //tu dong lay notification ve 
        setInterval(function() {
            $.ajax({
                type: "POST", 
                url  :"<?php echo site_url('admin/login/allnotifi') ?>",
                data        : null,
                success: function(data)
                {
            					
                    $('#content_notification').html(data);
                }
            });
        }, 1000);
        $('#send').click(function(){
            // var message = document.getElementById("textmessage").value;
            var user_receiver = $("#user_receiver").val();
            var message = $("#textmessage").val();
            $.ajax({
                type : 'POST' ,
                url   :"<?php echo base_url(); ?>index.php/admin/login/sendmessage?user_receiver="+user_receiver+"&&messages="+message,
                data : '',
                success: function(data)
                {
                    document.getElementById("textmessage").value ="" ;
                }
                                        
            }) ;
                                
        }) ;
                    
    });

</script>






